package org.example.newcoder_summer.service.impl;

import org.example.newcoder_summer.Mapper.UserMapper;
import org.example.newcoder_summer.pojo.User;
import org.example.newcoder_summer.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public User getById(int id) {
        return null;
    }

    @Override
    public void update(User user) {

    }

    @Override
    public User login(User user) {
        return userMapper.getByUserNameAndPassword(user);
    }

    @Override
    public void save(User user) {
        user.setIdentity(1);
        user.setLevel(1);
        user.setRegisterTime(LocalDateTime.now());
        user.setUpdateTime(LocalDateTime.now());
        userMapper.setUser(user);
    }
}
